import request from '@/utils/request'
import { ElMessage } from 'element-plus'

export function getGuestbookList() {
    return request({
        url: '/public/guestbook/list',
        method: 'get'
    }).catch(error => {
        ElMessage.error('获取留言列表失败: ' + error.message)
        throw error
    })
}

export function addGuestbook(content) {
    return request({
        url: '/public/guestbook/add',
        method: 'post',
        data: content,
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(response => {
        ElMessage.success('留言添加成功')
        return response
    }).catch(error => {
        ElMessage.error('留言添加失败: ' + error.message)
        throw error
    })
}